#!/bin/bash

# 测试machine_gb_type字段功能的脚本

echo "=== 测试machine_gb_type字段功能 ==="

# 1. 检查数据库表结构
echo "1. 检查machines_dashboard表结构..."
mysql -u root -p weaving_monitor -e "DESCRIBE machines_dashboard;" | grep machine_gb_type

# 2. 查看现有数据的machine_gb_type值
echo -e "\n2. 查看现有数据的machine_gb_type值..."
mysql -u root -p weaving_monitor -e "SELECT machine_number, machine_gb_type FROM machines_dashboard LIMIT 10;"

# 3. 更新一些测试数据，设置不同的machine_gb_type值
echo -e "\n3. 更新测试数据，设置不同的machine_gb_type值..."
mysql -u root -p weaving_monitor -e "
UPDATE machines_dashboard SET machine_gb_type = 3 WHERE machine_number = 1;
UPDATE machines_dashboard SET machine_gb_type = 4 WHERE machine_number = 2;
UPDATE machines_dashboard SET machine_gb_type = 1 WHERE machine_number = 3;
"

# 4. 验证更新结果
echo -e "\n4. 验证更新结果..."
mysql -u root -p weaving_monitor -e "SELECT machine_number, machine_gb_type FROM machines_dashboard WHERE machine_number IN (1,2,3);"

echo -e "\n=== 测试完成 ==="
echo "现在可以启动应用程序测试pattern和remaining值的交换功能"
